<template>
	<view>
		<view class="bottom-bow"></view>

		<view class="header">
			<view class="header-desc" @click="openMyDetailClick">
				<image class="header-bg" src="../../../static/images/wybr.png" />
				<view class="desc-wapper">
					<view class="name">{{mineData.empName}}</view>
					<view class="position">{{mineData.orgName}}：{{mineData.postName}}</view>
				</view>
				<view class="desc-portrait">
					<image :src="portrait" mode="aspectFill" />
				</view>
			</view>
		</view>
		<view class="list">
			<view class="item" @click="messageClick">
				<view class="item-icon">
					<image src="../../../static/images/xiaoxi.png" />
				</view>
				<view class="item-title bottom-underline">

					<text class="title">公告通知</text>
					<text class="mui-icon mui-icon-arrowright"></text>
				</view>
			</view>
			<view class="item" @click="ReportMatter">
				<view class="item-icon">
					<image src="../../../static/images/s_baoshi.png" />
				</view>
				<view class="item-title bottom-underline">
					<text class="title">报修历史</text>
					<text class="mui-icon mui-icon-arrowright"></text>
				</view>
			</view>
			<view class="item" @click="lookContact">
				<view class="item-icon">
					<image src="../../../static/images/tongxu.png" />
				</view>
				<view class="item-title bottom-underline">
					<text class="title">通讯录</text>
					<text class="mui-icon mui-icon-arrowright"></text>
				</view>
			</view>
			<view class="item" @click="settingClick">
				<view class="item-icon">
					<image src="../../../static/images/shezhi.png" />
				</view>
				<view class="item-title ">
					<text class="title">设置</text>
					<text class="mui-icon mui-icon-arrowright"></text>
				</view>
			</view>
			<view class="item" @click="disembark">
				<view class="item-icon">
					<image src="../../../static/images/tuichu.png" />
				</view>
				<view class="item-title">
					<text class="title">退出登录</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mineModule
	} from "../../../modules/mine.js"
	import util from "../../../utils/util.js"
	import {
		mapState,
		mapMutations
	} from 'vuex'
	const Mine = new mineModule()

	export default {
		data() {
			return {
				height: '',
				mineData: {}
			};
		},
		computed: {
			...mapState(['update']),
			portrait() {
				if (this.mineData) {
					return this.mineData.filesPrefix + this.mineData.filesPath
				}
			}
		},
		onLoad() {
			this.getMineDate()
		},
		onShow() { // 监听用户详情页 保存数据后 ，这里页面跟着更新
			if (this.update) {
				this.getMineDate()
				this.onUpdate()
			}
		},
		methods: {
			...mapMutations(['onUpdate']),
			getMineDate() { // 获取用户数据
				console.log('执行。。。')
				Mine.getMineData().then((res) => {
					this.mineData = res
				})
			},
			openMyDetailClick() { // 用户详情页
				uni.navigateTo({
					url: '/pages/mine/details/details'
				})
			},
			ReportMatter() { // 报事过往记录
				uni.navigateTo({
					url: '/pages/ReportMatter/history/history'
				})
			},
			messageClick() { // 公告
				uni.navigateTo({
					url: '/pages/notice/index/index'
				})
			},
			lookContact() { // 联系人
				uni.navigateTo({
					url: '/pages/home/mailList/mailList'
				})
			},

			settingClick() { // 设置
			
				const httpUrl = [
					'/pages/mine/ChangePasd/ChangePasd',
					'/pages/mine/about/about',
					'/pages/mine/feedback/feedback'
				]
			
				uni.showActionSheet({
					itemList: ['修改密码', '关于我们', '意见反馈'],
					success: function(res) {
						uni.navigateTo({
							url: httpUrl[res.tapIndex]
						})
						
					}
				});
			},

			disembark() { // 退出登录 
				uni.showModal({
					title: '提示',
					content: '退出登录后，将会清空您的用户信息',
					success(res) {
						if (res.confirm) {
							uni.removeStorageSync('userData')
							uni.reLaunch({
								url: '/pages/login/login/login'
							})
						}
					}
				});

			}

		}
	}
</script>

<style lang="scss">
	@import "../../../common/scss/common.scss";

	@import "index.scss";
</style>
